//
//  HomeTableViewController.swift
//  swiftWeiBoDemo
//
//  Created by zzw on 16/3/14.
//  Copyright © 2016年 zzw. All rights reserved.
//

import UIKit

class HomeTableViewController: BaseTableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        if !login{
         
        visitorView?.setupVisitorInfo(true,imageName:"visitordiscover_feed_image_home",message:"关注一些人，回这里看看有什么惊喜")
            
        }
         setupNav()
        
        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(HomeTableViewController.change), name: ZZWPopoverAnimatorWillShow, object: nil)
        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(HomeTableViewController.change), name: ZZWPopoverAnimatorWilldismiss, object: nil)
    }
    func change() {
        let btn  = navigationItem.titleView as! titleButton
        
        btn.selected = !btn.selected
        
    }
    
    private func setupNav(){
        //初始化左右按钮
        navigationItem.rightBarButtonItem = UIBarButtonItem.createUIBarButtonItem("navigationbar_pop", target: self, action: #selector(HomeTableViewController.rightItemClick))
        navigationItem.leftBarButtonItem = UIBarButtonItem.createUIBarButtonItem("navigationbar_friendattention", target: self, action: #selector(HomeTableViewController.leftItemClick))
        //初始化标题按钮
        let titleBtn = titleButton()
        titleBtn.setTitle("zzw ", forState: UIControlState.Normal)
        titleBtn.addTarget(self, action: #selector(HomeTableViewController.btnClikc), forControlEvents: UIControlEvents.TouchUpInside)
       navigationItem.titleView = titleBtn
        
    }
    func btnClikc(){
  
        let  sb = UIStoryboard(name: "PopoverViewController", bundle: nil)
        let vc = sb.instantiateInitialViewController()
        
        vc?.transitioningDelegate = popoverAnimator;
        vc?.modalPresentationStyle = UIModalPresentationStyle.Custom
        presentViewController(vc!, animated: true, completion: nil)
        
    }
    
   func leftItemClick(){
        print(#function)
        
    }
    func rightItemClick(){
        print(#function)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 0
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return 0
    }
    private lazy var popoverAnimator:PopoverAnimator = {
    
        let pa = PopoverAnimator()
        pa.presentFrame = CGRectMake(100, 56, 200, 350)
        return pa
    
    }()

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
